#ifndef SLIDEMODEL_H
#define SLIDEMODEL_H
#include <vector>
#include <QFile>
#include <QtXml>
#include "lp_types.h"

class SlideModel
{
    //A container for a memory-resident representation of an SVG DOM tree
    //---
    //The public interface allows manipulation of 'Tuples' in an STL list
    //that link in a way that preserves the hierarchical structure of an
    //XML-type document.
    //Methods are provided to 'convert' between an XML asset and the
    //tuple-based model
public:
    SlideModel(void);
    ~SlideModel(void);

    TupleItr AddTuple(Tuple pair);
    void RemoveTuple(TupleItr& pair);
    TupleItr GetRootTuple(void);
    TupleItr GetNullTuple(void);
    TupleItr GetFirstTupleWithParent(TupleItr parent);
    TupleItr GetNextSiblingForTuple(TupleItr element);

    void CacheContentsFromFile(QFile& inputTemplate);    
    bool InitialiseOutputDocument(const char* styleSheet);
    void FinaliseOutputDocument(void);

    QByteArray GetOutputDocAsByteArray(void);



private:
    QDomDocument* m_cachedTemplateDoc;
    QDomDocument* m_outputDoc;

    TupleItr m_outputXmlRoot;
    bool m_collectionHasRoot;
    std::list<Tuple> m_tupleCollection;

    inline bool tagNameIsDynamic(QString tagName);
    QDomNode getTupleRecursively(TupleItr& emItr);
};



#endif // SLIDEMODEL_H
